package com.bowlong.lang;

public class KeyValue<K, V> {
	public K key;
	public V value;

	public KeyValue() {
	}

	public KeyValue(K key, V value) {
		this.key = key;
		this.value = value;
	}

	public KeyValue<K, V> setKey(K key) {
		this.key = key;
		return this;
	}

	public K getKey() {
		return key;
	}

	public V getValue() {
		return value;
	}

	public KeyValue<K, V> setValue(V value) {
		this.value = value;
		return this;
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		KeyValue<K, V> that = (KeyValue<K, V>) o;
		if (key != null ? !key.equals(that.key) : that.key != null) {
			return false;
		}

		return true;
	}

	@Override
	public int hashCode() {
		int result = key != null ? key.hashCode() : 0;
		result = 31 * result + (value != null ? value.hashCode() : 0);
		return result;
	}

	@Override
	public String toString() {
		return key + " -> " + value;
	}

}
